Page({
  data: {
    showMeal:false,       //是否展示弹层
    showInputBottom: true,    //是否展示窗平米的下border
    showInputBottom2:true,    //是否展示扇数量的下border
    fanNum:'',                
    winArea:'',
    // select: false,
    tihuoWay: '门店自提',
    showSelectedArrLeft: [false, false, false, false],   //是否展示左侧的下拉选项-对应左侧的4个下拉面板开关
    showSelectedArrRight:[false,false,false,false],     //是否展示右侧的下拉选项-对应右侧的4个下拉面板开关
    selectedValueLeftArr:['','','',''],                 //保存左侧用户选择的下拉内容，每个数组元素代表左侧的某一行
    selectedValueRightArr: ['窗型选择', '窗型选择', '窗型选择','窗型选择'],             //保存右侧用户选择的下拉内容
    detailData:[
      {
        optionaimg:'http://wechat.shmengzai.com/yaohuaimg/optiona11.png',
        optionacontent:'铝材选配',
        optionabtn:'http://wechat.shmengzai.com/yaohuaimg/optional01.png',
        selected:false,
        selectedContentLeft:[         //左侧的下拉内容
          '铝材选配',
          '111111112312412421421412412412412421',
          '2222222'
        ],
        selectedContentRight:[        //右侧的下拉内容
          '窗型选择',
          '333352352352352352352352352352352',
          '444'
        ]
      },
      {
        optionaimg: 'http://wechat.shmengzai.com/yaohuaimg/optiona11.png',
        optionacontent: '玻璃选配',
        optionabtn: 'http://wechat.shmengzai.com/yaohuaimg/optional01.png',
        selected: false,
        selectedContentLeft: [
          '玻璃选配',
          'aaaa',
          'bbbb'
        ],
        selectedContentRight: [
          '窗型选择',
          'ccccc',
          'ddddd'
        ]
      },
      {
        optionaimg: 'http://wechat.shmengzai.com/yaohuaimg/optiona11.png',
        optionacontent: '玻璃选配',
        optionabtn: 'http://wechat.shmengzai.com/yaohuaimg/optional01.png',
        selected: false,
        selectedContentLeft: [
          '玻璃选配',
          '1111111',
          '2222222'
        ],
        selectedContentRight: [
          '窗型选择',
          '1111111111111',
          '22222222222222'
        ]
      },
      {
        optionaimg: 'http://wechat.shmengzai.com/yaohuaimg/optiona11.png',
        optionacontent: '玻璃选配',
        optionabtn: 'http://wechat.shmengzai.com/yaohuaimg/optional01.png',
        selected: false,
        selectedContentLeft: [
          '玻璃选配',
          '1111111',
          '2222222'
        ],
        selectedContentRight: [
          '窗型选择',
          '1111111111111',
          '22222222222222'
        ]
      },
    ]
    // opyiona:[{
    //   optionaimg: "http://wechat.shmengzai.com/yaohuaimg/optiona11.png",
    //   optionacontent: "选配",
    //   optionabtn: "http://wechat.shmengzai.com/yaohuaimg/optional01.png",
    //   optionabtn1: "http://wechat.shmengzai.com/yaohuaimg/optional02.png",
    // },
  },
  // onLoad: function (options) {
  //   wx.request({
  //     url: 'http:xxx/getWin',
      // data:{
      //   type:options.type
      // },
      // method:'post',
      // header:{
      //   accessToken:'gjwojgowjgwogwjgojjhlsjgwjgowho'
      // },
  //     success(res){
  //       console.log(res)
  //       this.setData({
  //       })
  //     }
  //   })
  //   if(options.name){
  //     wx.setNavigationBarTitle({
  //       title: options.name+'详情',
  //     })
  //   }
  // },
  clickItem: function (e) {
    wx.navigateTo({
      url: '../contact/index?name=' + e.currentTarget.dataset.name
    })
  },
  // 选择小圆圈
  // selectItem(e){
  //   const index = e.currentTarget.dataset.index
  //   const optionabtn = !this.data.detailData[index].selected == false ? 'http://wechat.shmengzai.com/yaohuaimg/optional01.png' :'http://wechat.shmengzai.com/yaohuaimg/optional02.png'
  //   const _optionabtn = 'detailData[' + index +'].optionabtn'
  //   const _selected = 'detailData[' + index +'].selected'
  //   this.setData({
  //     [_optionabtn]: optionabtn,
  //     [_selected]: !this.data.detailData[index].selected
  //   })
  // },
  // 展示左侧对应的下拉内容
  showSelectedLeftContent(e){
    const _index = e.currentTarget.dataset.index      //拿到最外层的索引
    // 把对应被点击的开关取反，其余全都关闭
    const showSelectedArrLeft = this.data.showSelectedArrLeft.map((item,index)=>{
      if(index == _index){
        return !item
      }else{
        return false
      }
    })
    this.setData({ showSelectedArrLeft})     //重新setData，把目前最新的开关状态给showSelectedArrLeft数组，渲染页面
  },
  // 获取左侧用户选择的下拉项
  getSelectedLeftContent(e){
    const parentIndex = e.currentTarget.dataset.parent  //获取父索引
    const index = e.currentTarget.dataset.index         //获取被点击项索引
    const value = this.data.detailData[parentIndex].selectedContentLeft[index]  //获取被点击的选项内容
    const xxx = 'selectedValueLeftArr[' + parentIndex + ']'     //
    const _optionabtn = 'detailData[' + parentIndex +'].optionabtn'
    this.setData({
      [xxx]: value,
      [_optionabtn]: index == 0 ? 'http://wechat.shmengzai.com/yaohuaimg/optional01.png' :'http://wechat.shmengzai.com/yaohuaimg/optional02.png',
      showSelectedArrLeft: [false, false, false, false]   //选完之后把左侧所有下拉面板收起
    })
  },
  // 展示右侧对应的下拉内容
  showSelectedRightContent(e){
    const _index = e.currentTarget.dataset.index
    const showSelectedArrRight = this.data.showSelectedArrRight.map((item,index)=>{
      if(index == _index){
        return !item
      }else{
        return false
      }
    })
    this.setData({ showSelectedArrRight})
  },
  // 获取右侧用户选择的下拉项
  getSelectedRightContent(e){
    const parentIndex = e.currentTarget.dataset.parent
    const index = e.currentTarget.dataset.index
    const value = this.data.detailData[parentIndex].selectedContentRight[index]
    const pi = 'selectedValueRightArr[' + parentIndex +']'
    this.setData({
      [pi]: value,
      showSelectedArrRight:[false,false,false,false]
    })
  },
  // 控制弹层是否显示
  changeMeal(e) {
    this.setData({
      showMeal: e.currentTarget.dataset.status || false
    })
  },
  // 获取用户填写的窗平米
  getInputValue(e) {
    this.setData({
      showInputBottom: !e.detail.value,     //控制下border是否显示
      winArea: e.detail.value               //保存用户填写的内容到this.data.winArea属性中
    })
  },
  // 获取用户填写的扇数量
  getInputValue2(e) {
    this.setData({
      showInputBottom2: !e.detail.value,
      fanNum: e.detail.value
    })
  },
  onShareAppMessage(){
    return {
      title: '分享',
      path: '/pages/index/index',
      // imageUrl: shareImageUrl
    }
  }
})